/**
 * Created by ss on 15/12/23.
 */
import $ from "jquery";
let Helper = {
    winWidth : $(window).width(),
    winHeight : $(window).height(),
    init(){
        this.initRem();
    },
    initRem(){
        $("html").css("font-size",this.winWidth/3.2+"px");
    },
    hackDate(str){
        var reg = new RegExp('-',"g");
        try{
            var date = new Date(str.replace(reg,'/'));
            return date;
        }catch(e){
            var ymd = (str.split(' '))[0];
            var hms = (str.split(' '))[1];
            var ymdArray = ymd.split('-');
            var hmsArray = hms.split(':');
            var year = parseInt(ymdArray[0]);
            var month = parseInt(ymdArray[1])-1;
            var day = parseInt(ymdArray[2]);
            var hour = parseInt(hmsArray[0]);
            var minute = parseInt(hmsArray[1]);
            var second = parseInt(hmsArray[2]);
            return new Date(year,month,day,hour,minute,second);
        }
    },
    ajax(config){
        var preUrl = "http://120.26.83.168:8081/ws";
        config.url = preUrl + config.url ;
        return $.ajax(config);
    },
    urlGet(){
        var aQuery = window.location.href.split("?");//取得Get参数
        var aGET = new Array();
        if(aQuery.length > 1)
        {
            var aBuf = aQuery[1].split("&");
            for(var i=0, iLoop = aBuf.length; i<iLoop; i++)
            {
                aBuf[i] = (aBuf[i].split("#"))[0];
                var aTmp = aBuf[i].split("=");//分离key与Value
                aGET[aTmp[0]] = aTmp[1];
            }
        }
        return aGET;
    }
}
export default Helper;